﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConstructingSpiralMatrix
{
    class Program
    {
        static void Main(string[] args)
        {
            int dimentionOfMatrix = int.Parse(Console.ReadLine());
            int rightDirection = dimentionOfMatrix;
            int downDirection = dimentionOfMatrix - 1;
            int leftDirection = dimentionOfMatrix - 1 ;
            int upDirection = dimentionOfMatrix - 2;
            int numberOfElementsInMatrix = dimentionOfMatrix * dimentionOfMatrix;

            int[,] spiralMatrix = new int[dimentionOfMatrix,dimentionOfMatrix];

            int elementsInCounter = 1;
            int numberOfIteration = 0; // na koe zavyrtane sme

            while (elementsInCounter <= numberOfElementsInMatrix )
            {
                //1
                for (int index = numberOfIteration, elements = 1; elements <= rightDirection; index++, elements++)
                {
                    spiralMatrix[numberOfIteration, index] = elementsInCounter++;
                }
                //elements pokazva kolko elementa trqbva da se slojat
                rightDirection -= 2;
                
                for (int index = numberOfIteration + 1 ,elements = 1; elements <= downDirection; index++, elements++)
                {
                    spiralMatrix[index,dimentionOfMatrix - 1 - numberOfIteration] = elementsInCounter++;
                }
                downDirection -= 2;

               
                //2
                for (int index = dimentionOfMatrix - 2 - numberOfIteration, elements = 1; 
                    elements <= leftDirection ; index--,elements++)
                {
                    spiralMatrix[ dimentionOfMatrix - 1 - numberOfIteration, index] = elementsInCounter++;
                }
                leftDirection -= 2;
                 
                //3
                for (int index = dimentionOfMatrix - 2 - numberOfIteration, elements = 1;
                    elements <= upDirection ; index--,elements++)
                {
                    spiralMatrix[index, numberOfIteration] = elementsInCounter++;
                }

                upDirection -= 2;

                
                numberOfIteration++;
            }

            for (int index = 0; index < spiralMatrix.GetLength(0); index++)
            {
                for (int column = 0; column < spiralMatrix.GetLength(1); column++)
                {
                    Console.Write(spiralMatrix[index, column] + "\t");
                }
                Console.WriteLine();
            }

            
        }
    }
}
